package com.entity;

import com.annotation.ColumnInfo;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.FieldFill;
import com.baomidou.mybatisplus.enums.IdType;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.util.Date;

/**
 * 聊天消息实体类
 */
@TableName("chat_message")
@Data
public class ChatMessageEntity implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 主键
     */
    @TableId(type = IdType.AUTO)
    @ColumnInfo(comment="主键",type="bigint(20)")
    @TableField(value = "id")
    private Long id;

    /**
     * 消息内容
     */
    @ColumnInfo(comment="消息内容",type="text")
    @TableField(value = "content")
    private String content;

    /**
     * 发送者ID
     */
    @ColumnInfo(comment="发送者ID",type="varchar(50)")
    @TableField(value = "sender_id")
    private String senderId;

    /**
     * 接收者ID
     */
    @ColumnInfo(comment="接收者ID",type="varchar(50)")
    @TableField(value = "receiver_id")
    private String receiverId;

    /**
     * 消息类型：text-文本，image-图片，file-文件
     */
    @ColumnInfo(comment="消息类型",type="varchar(20)")
    @TableField(value = "message_type")
    private String messageType;

    /**
     * 是否已读：0-未读，1-已读
     */
    @ColumnInfo(comment="是否已读",type="tinyint(1)")
    @TableField(value = "is_read")
    private Integer isRead;

    /**
     * 创建时间
     */
    @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat
    @ColumnInfo(comment="创建时间",type="timestamp")
    @TableField(value = "create_time",fill = FieldFill.INSERT)
    private Date createTime;

    /**
     * 更新时间
     */
    @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat
    @ColumnInfo(comment="更新时间",type="timestamp")
    @TableField(value = "update_time",fill = FieldFill.INSERT_UPDATE)
    private Date updateTime;
}
